package com.zhao.controller;


import com.zhao.Result;
import com.zhao.entity.EduVideo;
import com.zhao.service.EduVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author xiaozhao
 * @since 2021-07-26
 */
@RestController
@RequestMapping("eduservice/video")
@CrossOrigin
public class EduVideoController {

    @Autowired
    private EduVideoService videoService;

    //添加小节信息
    @PostMapping("/addVideo")
    public Result addVideo(@RequestBody EduVideo video){
        System.out.println(video);
        videoService.save(video);
        return Result.ok();
    }
    //根据小节id获取小节信息
    @GetMapping("/findVideoById/{id}")
    public Result findVideoById(@PathVariable String id){
        EduVideo video = videoService.getById(id);
        return Result.ok().data("video",video);
    }
    //根据小节id修改小节信息
    @PostMapping("/updateVideoById")
    public Result updateVideoById(@RequestBody EduVideo video){
        videoService.updateById(video);
        return Result.ok();
    }
    //根据小节id获取小节信息
    @PostMapping("/removeVideoById/{id}")
    public Result removeVideoById(@PathVariable String id){
        videoService.removeById(id);
        return Result.ok();
    }

}

